﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Skugo.StandardPlugins
{
    /// <summary>
    /// Interaction logic for CommandUIElement.xaml
    /// </summary>
    public partial class CommandUIElement : UserControl
    {
        internal Command Source;
        internal CommandSearch Searcher;

        public CommandUIElement(Command source, CommandSearch searcher)
        {
            InitializeComponent();
            this.Source = source;
            this.Searcher = searcher;
        }

        private void Expander_Expanded(object sender, RoutedEventArgs e)
        {
            foreach (CommandUIElement element in this.Searcher.Commands.Items)
            {
                if (element != this)
                {
                    element.ExpandTooltip.IsExpanded = false;
                }
            }

            this.DescriptionPopup.IsOpen = true;
            if (this.Source.Description == String.Empty)
            {
                this.Description.Text = "(No Description)";
            }
            else
            {
                this.Description.Text = this.Source.Description;
            }
        }

        private void ExpandTooltip_Collapsed(object sender, RoutedEventArgs e)
        {
            this.DescriptionPopup.IsOpen = false;
        }
    }
}
